﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;

namespace GameLibrary.Input
{
    public class CKey
    {
        Keys KeyCode;
        bool Last;
        bool Current;

        public bool Pressed;
        public bool Released;
        public bool Hold;
        public bool Untouched;
        public bool Toggled = false;

        public CKey(Keys key)
        {
            KeyCode = key;
            Current = Last = Pressed
            = Released = false;
        }

        public void Update()
        {
            KeyboardState keybState = Keyboard.GetState();

            Last = Current;
            Current = keybState.IsKeyDown(KeyCode);
            Pressed = (Current && !Last);
            Released = (!Current && Last);
            Hold = (Current && Last);
            Untouched = (!Current && !Last);

            if (Pressed)
                Toggled = !Toggled;

        }
    }
}
